
var datagrid = require('datagrid');
var router = require('router');
var update = require('./update');

return extend('./main', {
    target:'#sysMessage',
    path:'/message/',
    events:{
        'click .sysMessage-detail':'getData detail update'
    },
    onInit:function(){
        datagrid({
            isBorder:false,
            fields:'id',
            container:this.element.find('.m-message-body'),
            placeholder:'暂无消息',
            paging:{
                url:sourceHttp
            },
            columns:[{
                title:'',
                width:20,
                content:'',
                style:{
                    border:'none',
                    padding:'0px',
                    background:'#fff'
                }
            }, {
                content:'checkbox',
                width:60,
                align:'left'
            }, {
                title:'<a class="j-readed">标记为已读</a><b class="e-ml8 e-mr8">|</b><a class="j-delete">删除</a>',
                field:'buname',
                align:'left',
                filter:function(val, field, data){
                    return '<a class="sysMessage-detail">'+ val +'</a>'
                }
            }, {
                title:'',
                field:'buname',
                align:'left',
                width:'20%'
            }, {
                title:'',
                field:'buname',
                align:'right',
                width:'20%'
            }, {
                title:'',
                width:20,
                content:'',
                style:{
                    border:'none',
                    padding:'0px',
                    background:'#fff'
                }
            }]
        })
    },
    detail:function(e, elem, data){
        router.location(this.data.path + data.id, true);
        if(elem.hasClass('s-readed')){
            return false
        }
    },
    update:update
})